package com.drinkian.business.good.controller;

import com.drinkian.business.good.entity.po.Good;
import com.drinkian.business.good.entity.vo.VGoodAdd;
import com.drinkian.business.good.service.IGoodService;
import com.drinkian.entity.RequestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("good")
public class GoodController {


    @Autowired
    private IGoodService iGoodService;

    @PostMapping("addGood")
    public RequestResult addGood(@RequestBody VGoodAdd vGoodAdd) {
        return iGoodService.addGood(vGoodAdd);
    }

    @GetMapping("getGoodList")
    public RequestResult getGoodList(@RequestParam("current") int current, @RequestParam("size") int size) {
        return iGoodService.getGoodList(current, size);
    }

    @GetMapping("searchGood")
    public RequestResult searchGood(@RequestParam("name") String name) {
        return iGoodService.searchGood(name);
    }


    @GetMapping("getGoodListByUploaderId")
    public RequestResult getGoodListByUploaderId(@RequestParam("id") int id, @RequestParam("current") int current, @RequestParam("size") int size) {
        return iGoodService.getGoodListByUploaderId(id, current, size);
    }

    @GetMapping("deleteGoodById")
    public RequestResult deleteGoodById(@RequestParam("id") int id) {
        return iGoodService.deleteGoodById(id);
    }

    @PostMapping("updateGood")
    public RequestResult updateGood(@RequestBody Good good){
        return iGoodService.updateGood(good);
    }

    @GetMapping("getUncheckGoodList")
    public RequestResult getUncheckGoodList(@RequestParam("current")Integer current, @RequestParam("size")Integer size){
        return iGoodService.getUncheckGoodList(current, size);
    }

    @GetMapping("examUncheckGood")
    public RequestResult examUncheckGood(@RequestParam("goodId")Integer goodId, @RequestParam("code")Integer code){
        return iGoodService.examUncheckGood(goodId, code);
    }
}
